"""
Case Type   : ustore-Consistency
Case Name   : 清理环境 
Create At   : 2022/10/28
Owner       : @zou_jialiang050
Description :
    1.清理环境
Expect      :
    1.成功
History     :
    modified by @zou_jialiang050 2022/10/24:修改用例,触发执行
    modified by @zou_jialiang050 2022/10/28:修改用例,触发执行
    modified by @zou_jialiang050 2022/11/15:修改用例,触发执行
"""

import os
import unittest
from testcase.utils.Logger import Logger
from testcase.utils.CommonSH import CommonSH
from testcase.utils.Constant import Constant


class CONSISTENCY(unittest.TestCase):
    def setUp(self):
        self.pri_sh = CommonSH('PrimaryDbUser')
        self.constant = Constant()
        self.log = Logger()
        self.log.info(f'-----{os.path.basename(__file__)} start-----')
        self.schema1 = 's_ustore_consistency_01'
        self.schema2 = 's_ustore_consistency_02'

    def test_ustore_consistency(self):
        text1 = 'step1:清理环境 expect:成功'
        self.log.info(text1)
        drop_schema = self.pri_sh.execut_db_sql(
            f'''drop schema {self.schema1} cascade;
            drop schema {self.schema2} cascade;''')
        self.log.info(drop_schema)
        self.assertEqual(
            drop_schema.count(self.constant.DROP_SCHEMA_SUCCESS_MSG), 
            2, '执行失败' + text1)

    def tearDown(self):
        self.log.info('-----无需清理环境-----')
        self.log.info(f'-----{os.path.basename(__file__)} end-----')
        